import axios from '@/api/interceptor';
import type { AutocompleteParams } from './types';

export const selectPageArticleFront = async (params :any) => {
  const result = await axios({
    url: '/articleFront/listPage',
    method: 'GET',
    params,
  });
  return result.data;
};

export const selectRecommend = async () => {
  const result = await axios({
    url: '/articleFront/recommend',
    method: 'GET',
  });
  return result.data;
};

export const selectRecent = async () => {
  const result = await axios({
    url: '/articleFront/recent',
    method: 'GET',
  });
  return result.data;
};

export const selectArticles = async () => {
  const result = await axios({
    url: '/articleFront/list',
    method: 'GET',
  });
  return result.data;
};

export const selectListCategory = async (id:string) => {
  const result = await axios({
    url: '/articleFront/listCategory',
    method: 'GET',
    params: {id}
  });
  return result.data;
};

export const selectRank = async () => {
  const result = await axios({
    url: '/articleFront/rank',
    method: 'GET',
  });
  return result.data;
};

export const getArticleDetail = async (id:any) => {
  const result = await axios({
    url: '/articleFront/getArticleDetail',
    method: 'GET',
    params: { id },
  });
  return result.data;
};

export const searchPageArticleFront = async (params :any) => {
  const result = await axios({
    url: '/articleFront/portal',
    method: 'GET',
    params,
  });
  return result.data;
};

export const getAutocomplete = async (params: AutocompleteParams) => {
  const result = await axios({
    url: '/articleFront/autocomplete',
    method: 'GET',
    params,
  });
  return result.data;
};
